/*
* app数据中心，所有业务层静态数据都从这里取得
* */
import '../base/beans/jcring_bean.dart';
import '../base/log.dart';
import '../network/jcserver/jc_server_data.dart';
import '../network/proxy/proxy_data.dart';

/*
* APP数据类，所有数据都从这个类获取
* */
class APPDatabase {
  static int serverProfile = 1;
  static const _tag = '[app_data.dart][APPDatabase]';
  int currentFamilyId = 0;
  static late DataProxy _dataProxy;

  static void init() {
    // 初始化
    switch (serverProfile) {
      case 0: //无服务器
        break;
      case 1: //JC云服务器
        _dataProxy = JcServerData();
        break;
      default:
        DartLog.i(_tag, 'ERROR! not select any server');
        break;
    }
    _dataProxy.init();
  }

  static Future<bool> saveWomanHealthData(
      String userToken,
      String periodStartTime,
      String periodTwoStartTime,
      int periodLenth,
      int period,
      int regularly,
      int tracking) async {
    return await _dataProxy.saveWomanHealthData(userToken, periodStartTime, periodTwoStartTime, periodLenth, period, regularly, tracking);
  }

  static Future<bool> saveHealthRecordData(
      String userToken,
      String day,
      int flowRate,
      int colorRate,
      int dysmenorrhea,
      List<int> symptoms,
      int leucorrhea,
      int mood,
      int ovulation,
      int love,
      String notes) async {
    return await _dataProxy.saveHealthRecordData(userToken, day, flowRate, colorRate, dysmenorrhea, symptoms, leucorrhea, mood, ovulation, love, notes);
  }

  static Future<List<MenstrualRecord>> queryHealthRecordData(String userToken, String startDate, String endDate) async {
    return await _dataProxy.queryHealthRecordData(userToken, startDate, endDate);

  }

  static Future<Map<String, dynamic>> queryWomanHealthData(String userToken) async {
    return await _dataProxy.queryWomanHealthData(userToken);
  }
}
